home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Date & Calendars / date-menu.izs < prev    next >
Text File  |  2005-07-11  |  5KB  |  214 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Date Menu
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>This script uses the Date function to dynamically generate accurate dates for the pull-down menus<!/DESCRIPTION> 
  7.  
  8. <!CATEGORY>calenders<!/CATEGORY>
  9.  
  10. <!SCRIPT>
  11. <!-- START OF SCRIPT -->
  12.  
  13. <!-- TWO STEPS TO INSTALL DATE MENU:
  14.  
  15.   1.  Copy the coding into the HEAD of your HTML document
  16.   2.  Add the last code into the BODY of your HTML document  -->
  17.  
  18. <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->
  19.  
  20. <HEAD>
  21.  
  22. <SCRIPT LANGUAGE="JavaScript">
  23. <!-- Original:  Ben McFarlin (mcfarlin@netscape.net) -->
  24. <!-- Web Site:  http://sites.netscape.net/mcfarlin -->
  25.  
  26.  
  27.  
  28. <!-- Begin
  29. function populate(objForm,selectIndex) {
  30. timeA = new Date(objForm.year.options[objForm.year.selectedIndex].text, objForm.month.options[objForm.month.selectedIndex].value,1);
  31. timeDifference = timeA - 86400000;
  32. timeB = new Date(timeDifference);
  33. var daysInMonth = timeB.getDate();
  34. for (var i = 0; i < objForm.day.length; i++) {
  35. objForm.day.options[0] = null;
  36. }
  37. for (var i = 0; i < daysInMonth; i++) {
  38. objForm.day.options[i] = new Option(i+1);
  39. }
  40. document.f1.day.options[0].selected = true;
  41. }
  42. function getYears() {
  43.  
  44. // You can easily customize what years can be used
  45. var years = new Array(1997,1998,1999,2000,2001,2005)
  46.  
  47. for (var i = 0; i < document.f1.year.length; i++) {
  48. document.f1.year.options[0] = null;
  49. }
  50. timeC = new Date();
  51. currYear = timeC.getFullYear();
  52. for (var i = 0; i < years.length; i++) {
  53. document.f1.year.options[i] = new Option(years[i]);
  54. }
  55. document.f1.year.options[2].selected=true;
  56. }
  57. window.onLoad = getYears;
  58. //  End -->
  59. </script>
  60. </HEAD>
  61.  
  62. <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->
  63.  
  64. <BODY>
  65.  
  66. <center>
  67. <form name=f1>
  68. <table border=0>
  69. <tr>
  70. <td align=center>
  71. <select name=year onChange="populate(this.form,this.form.month.selectedIndex);">
  72. <option selected value=99>1999</option>
  73. <option value=00>2000</option>
  74. <option value=01>2001</option>
  75. <option value=02>2002</option>
  76. </select>
  77.  
  78. <select name=month onChange="populate(this.form,this.selectedIndex);">
  79. <option value=01>January</option>
  80. <option value=02>February</option>
  81. <option value=03>March</option>
  82. <option value=04>April</option>
  83. <option value=05>May</option>
  84. <option value=06>June</option>
  85. <option value=07>July</option>
  86. <option value=08>August</option>
  87. <option value=09>September</option>
  88. <option value=10>October</option>
  89. <option value=11>November</option>
  90. <option value=12>December</option>
  91. </select>
  92.  
  93. <select name=day>
  94. <option>  </option>
  95. <option>  </option>
  96. <option>  </option>
  97. <option>  </option>
  98. <option>  </option>
  99. <option>  </option>
  100. <option>  </option>
  101. </select>
  102. </td>
  103. </tr>
  104. </table>
  105. </form>
  106. </center>
  107.  
  108. <!-- END OF SCRIPT -->
  109. <!/SCRIPT>
  110.  
  111. <!PREVIEW>
  112. <!-- START OF SCRIPT -->
  113.  
  114.  
  115. <!-- TWO STEPS TO INSTALL DATE MENU:
  116.  
  117.   1.  Copy the coding into the HEAD of your HTML document
  118.   2.  Add the last code into the BODY of your HTML document  -->
  119.  
  120. <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->
  121.  
  122. <HEAD>
  123.  
  124. <SCRIPT LANGUAGE="JavaScript">
  125. <!-- Original:  Ben McFarlin (mcfarlin@netscape.net) -->
  126. <!-- Web Site:  http://sites.netscape.net/mcfarlin -->
  127.  
  128.  
  129.  
  130. <!-- Begin
  131. function populate(objForm,selectIndex) {
  132. timeA = new Date(objForm.year.options[objForm.year.selectedIndex].text, objForm.month.options[objForm.month.selectedIndex].value,1);
  133. timeDifference = timeA - 86400000;
  134. timeB = new Date(timeDifference);
  135. var daysInMonth = timeB.getDate();
  136. for (var i = 0; i < objForm.day.length; i++) {
  137. objForm.day.options[0] = null;
  138. }
  139. for (var i = 0; i < daysInMonth; i++) {
  140. objForm.day.options[i] = new Option(i+1);
  141. }
  142. document.f1.day.options[0].selected = true;
  143. }
  144. function getYears() {
  145.  
  146. // You can easily customize what years can be used
  147. var years = new Array(1997,1998,1999,2000,2001,2005)
  148.  
  149. for (var i = 0; i < document.f1.year.length; i++) {
  150. document.f1.year.options[0] = null;
  151. }
  152. timeC = new Date();
  153. currYear = timeC.getFullYear();
  154. for (var i = 0; i < years.length; i++) {
  155. document.f1.year.options[i] = new Option(years[i]);
  156. }
  157. document.f1.year.options[2].selected=true;
  158. }
  159. window.onLoad = getYears;
  160. //  End -->
  161. </script>
  162. </HEAD>
  163.  
  164. <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->
  165.  
  166. <BODY>
  167.  
  168. <center>
  169. <form name=f1>
  170. <table border=0>
  171. <tr>
  172. <td align=center>
  173. <select name=year onChange="populate(this.form,this.form.month.selectedIndex);">
  174. <option selected value=99>1999</option>
  175. <option value=00>2000</option>
  176. <option value=01>2001</option>
  177. <option value=02>2002</option>
  178. </select>
  179.  
  180. <select name=month onChange="populate(this.form,this.selectedIndex);">
  181. <option value=01>January</option>
  182. <option value=02>February</option>
  183. <option value=03>March</option>
  184. <option value=04>April</option>
  185. <option value=05>May</option>
  186. <option value=06>June</option>
  187. <option value=07>July</option>
  188. <option value=08>August</option>
  189. <option value=09>September</option>
  190. <option value=10>October</option>
  191. <option value=11>November</option>
  192. <option value=12>December</option>
  193. </select>
  194.  
  195. <select name=day>
  196. <option>  </option>
  197. <option>  </option>
  198. <option>  </option>
  199. <option>  </option>
  200. <option>  </option>
  201. <option>  </option>
  202. <option>  </option>
  203. </select>
  204. </td>
  205. </tr>
  206. </table>
  207. </form>
  208. </center>
  209.  
  210.  
  211. <!-- END OF SCRIPT -->
  212. <!/PREVIEW>
  213.  
  214. <!RELATED>NONE<!/RELATED>